#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=50009;
const ll SIZE=400;
ll n,m,x[N];
ll ans[SIZE][SIZE];//ans[p][v]表示编号模p余v的数值总和
ll L;
void solveBF(){
    //暴力求解，当p较大时较快
    for(ll iQ=1;iQ<=m;iQ++){
        char op;//Query or Update?
        ll p,v;
        cin>>op>>p>>v;
        if(op=='Q'){//Query
            ll sum=0;
            for(ll i=v;i<=n;i+=p)
                sum+=x[i];//编号为k*p+v的都满足
            cout<<sum<<" ";
        }
        else
            x[p]=v;//Update
    }
}
void precompute(){//预处理
    for(ll p=1;p<=L;p++)
        for(ll i=1;i<=n;i++)
            ans[p][i%p]+=x[i];
}
void update(ll id,ll v){
    for(ll p=1;p<=L;p++)
        ans[p][id%p]+=v-x[id];
    x[id]=v;
}
void solveMath(){
    L=sqrt(m*n/(2*n+m));
    precompute();
    for(ll iQ=1;iQ<=m;iQ++){
        char op;
        ll p,v;
        cin>>op>>p>>v;
        if(op=='Q'){//Query
            if(p<=L)//p较小时暴力枚举时间复杂度高
                cout<<ans[p][v]<<" ";
            else{//p较大时暴力枚举时间复杂度低
                ll sum=0;
                for(ll i=v;i<=n;i+=p)
                    sum+=x[i];//编号为k*p+v的都满足
                cout<<sum<<" ";
            }
        }
        else update(p,v);//Update
    }
}
int main(){
    freopen("mod.in","r",stdin);
    freopen("mod.out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>x[i];
    solveMath();
    return 0;
}